package com.estate.business.impl;

import java.util.Date;
import java.util.List;

import com.estate.business.TenderChangeService;
import com.estate.dao.TenderChangeDao;
import com.estate.utils.DeleProjectUtil;
import com.estate.vo.Vo;
import com.estate.vo.impl.DeleProjectVo;
import com.estate.vo.impl.TenderChangeVo;

public class TenderChangeServiceImpl implements TenderChangeService {

	private TenderChangeDao tenderChangeDao;

	public TenderChangeDao getTenderChangeDao() {
		return tenderChangeDao;
	}

	public void setTenderChangeDao(TenderChangeDao tenderChangeDao) {
		this.tenderChangeDao = tenderChangeDao;
	}
	
	public boolean addTenderChange(TenderChangeVo tenderChange) {
		boolean result =false; 
		result = this.getTenderChangeDao().addVo(tenderChange);
		return result;
	}

	public List<Vo> getTenderChangeList(){
		List<Vo> allList = this.getTenderChangeDao().findAll();
		return allList;
	}

	public TenderChangeVo getTenderChange(int id) {
		TenderChangeVo tenderChange = (TenderChangeVo) this.getTenderChangeDao().findByPK(id);
		return tenderChange;
	}

	public boolean updateTenderChange(TenderChangeVo tenderChange) {
		boolean result =false;
		TenderChangeVo old = this.getTenderChange(tenderChange.getId());
		tenderChange.setPostDate(old.getPostDate());
		
		tenderChange.setPostUser(old.getPostUser());
		tenderChange.setTender(old.getTender());
		
		result = this.getTenderChangeDao().updateVo(tenderChange);
		
		return true;
	}
	public boolean deleteMultiTenderChange(String delStr){
		if(delStr!= null && !"".equals(delStr) && !",".equals(delStr)){
			String[] delArray = delStr.split(",");
			TenderChangeVo tenderChange = null;
			for(int i = 0;i<delArray.length;i++){
				tenderChange = new TenderChangeVo();
				tenderChange.setId(Integer.parseInt(delArray[i]));
				this.deleteTenderChange(tenderChange);
			}
		}
		return true;
	}
	
	public boolean deleteTenderChange(TenderChangeVo tenderChange){
		boolean result = false;
		result = this.getTenderChangeDao().deleteVo(tenderChange);
		return result;
	}
}
